#!/bin/sh
#
# Copyright (C) 2000-2019 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# test only the disk based regression scripts
#
# Include full output
LANG=C
echo "Begin nightly-disk `date`"
REGRESS_DEBUG=1
export REGRESS_DEBUG
CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE=2000000
export CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
rm -rf Testing
rm -f dumps/*
git pull
#
# Temp switch to branch Branch-5.0 NB this leaves you on a headless
#    branch, but it works for building and testing.
#
#git checkout `git branch -r | grep "5\.0" | head -1`
#if [ $? -ne 0 ]; then
#   git checkout master
#fi
make distclean
scripts/config_dart
make setup
nice ctest --output-on-failure -D Nightly -R "^disk:"
rtn=$?
i=0
while [ $i -le 5 ]; do
   # No idea what is the return 3
   if [ $rtn = 0 -o "$rtn" = "8" -o "$rtn" = 3 -o  "$rtn" = 11 ]; then
      break;
   fi
   echo "Submit failed, waiting 5 mins rtn=$rtn"
   sleep 300
   echo "ctest failed re-running Submit"
   ctest -D NightlySubmit
   rtn=$?
   i=`expr $i + 1`
done
echo "End nightly-disk `date`"
